#!/usr/bin/env python

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

import sys

files=[]

if len(sys.argv) == 1:
	files=[sys.stdin]
else:
	for i in sys.argv[1:]:
		try:
			fp=open(i,"rb")
		except:
			print "File "+i+" not found or not a file"
			sys.exit(1)
		else:
			files.append(fp)

lines=[]

for file in files:
	for line in file:
		lines.append(line,)
	for i in range(len(lines)-1,-1,-1):
		print lines[i],
	if file!=sys.stdin:
		file.close()
